Allow the XenAPI Session object to have login_with_password called as a
authorEwan Mellor <ewan@xensource.com>
Fri, 15 Dec 2006 17:18:02 +0000 (17:18 +0000)
committerEwan Mellor <ewan@xensource.com>
Fri, 15 Dec 2006 17:18:02 +0000 (17:18 +0000)
methodname, to re-login through the same object (say when the server is
restarted).

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xm/XenAPI.py
tools/python/xen/xm/main.py

index a7835c0ebce15fde40230b18746434e20122f6b6..1c1bc41e948186f5e44c13969b300546ee84d09e 100644 (file)
@@ -83,8 +83,12 @@ class Session(xen.util.xmlrpclib2.ServerProxy):
 
 
     def xenapi_request(self, methodname, params):
-        full_params = (self._session,) + params
-        return _parse_result(getattr(self, methodname)(*full_params))
+        if methodname.startswith('login'):
+            self._login(methodname, *params)
+            return None
+        else:
+            full_params = (self._session,) + params
+            return _parse_result(getattr(self, methodname)(*full_params))
 
 
     def _login(self, method, username, password):
index 059bbd46b220ac467bd124805bd08fe59510288a..a503835cf5c6ede5102a036ff78a747fc4135571 100644 (file)
@@ -558,7 +558,7 @@ class Shell(cmd.Cmd):
                 ok, res = _run_cmd(lambda x: server.xenapi_request(words[0],
                                                                    tuple(x)),
                                    words[0], words[1:])
-                if ok and res != '':
+                if ok and res is not None and res != '':
                     pprint.pprint(res)
             else:
                 print '*** Unknown command: %s' % words[0]